package br.edu.ufcg.lsd.wbis.ui.client.ui.loggedin.admin.searchusers;

import br.edu.ufcg.lsd.wbis.ui.client.beans.UserInfo;
import br.edu.ufcg.lsd.wbis.ui.client.ui.management.InfoManager;

import com.gwtext.client.core.EventObject;
import com.gwtext.client.widgets.Button;
import com.gwtext.client.widgets.TabPanel;
import com.gwtext.client.widgets.event.ButtonListenerAdapter;

/**
 * @author Renato Miceli
 */
public class SearchButtonListener extends ButtonListenerAdapter {

	private final SearchUsersFormPanel searchPanel;

	private final TabPanel centerPanel;

	private final InfoManager<UserInfo> infoManager;

	/**
	 * @param searchPanel
	 * @param centerPanel
	 */
	public SearchButtonListener(SearchUsersFormPanel searchPanel, TabPanel centerPanel, InfoManager<UserInfo> infoManager) {
		this.searchPanel = searchPanel;
		this.centerPanel = centerPanel;
		this.infoManager = infoManager;
	}

	/**
	 * {@inheritDoc}
	 */
	@Override
	public void onClick(Button button, EventObject e) {
		ShowSearchedUsersTab panel = new ShowSearchedUsersTab(searchPanel.parseForm(), centerPanel, infoManager);
		centerPanel.add(panel);
		centerPanel.activate(panel.getId());
	}

}
